package com.ssm.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.sfzy.entity.HeartMark;
import com.ssm.sfzy.mapper.HeartMarkMapper;
import com.ssm.sfzy.service.HeartMarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author fuyanru
 * @date 2024年03月30日 10:41
 */
@Service
public class HeartMarkServiceImpl implements HeartMarkService {
    @Autowired
    private HeartMarkMapper heartMarkMapper;
    @Override
    public void add(HeartMark entity) {
        heartMarkMapper.insert(entity);
    }

    @Override
    public void edit(HeartMark entity) {
          heartMarkMapper.update(entity);
    }

    @Override
    public void remove(Integer id) {
       heartMarkMapper.delete(id);
    }

    @Override
    public void removeBatch(Integer[] ids) {
       heartMarkMapper.deleteBatch(ids);
    }

    @Override
    public List<HeartMark> find(HeartMark entity) {
        return heartMarkMapper.select(entity);
    }


    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, HeartMark entity) {
        PageHelper.startPage(pageNum,pageSize);
        List<HeartMark> list = heartMarkMapper.select(entity);
        //
        PageInfo<HeartMark> pageInfo = new PageInfo<>(list);
        // 整合处理
        Map<String,Object> map = new HashMap<>();
        map.put("list",pageInfo.getList());
        map.put("total",pageInfo.getTotal());
        return map;
    }

    @Override
    public HeartMark findById(Integer id) {
        return heartMarkMapper.selectById(id);
    }


}
